<?php


namespace seecms\lib;

use seecms\lib\provider\User;
use seecms\See;

class Auth
{

    public static function user(): User
    {
        return See::provider()->user;
    }

    /**
     * 密码加密
     * @param $password
     * @param $algo
     * @return string
     */
    public static function password($password, $algo = null): string
    {
        $password = trim($password);
        $algo = $algo ?: PASSWORD_DEFAULT;

        return password_hash($password, $algo);
    }

    /**
     * @param $input_password
     * @param string $user_password
     * @return bool
     */
    public static function checkPassword($input_password, string $user_password): bool
    {
        if (empty($input_password) || empty($user_password)) {
            return false;
        }

        if (password_verify($input_password, $user_password)) {
            return true;
        }

        return false;
    }
}